package com.ruoyi.pingjiao.mapper;

import com.ruoyi.pingjiao.domain.AchievementDistribution;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AchievementDistributionMapper {

    @Insert("insert into achievement_distribution (coureassess_id, achievement_ratio, stu_number, proportion)" +
            " values (#{coureassessId},#{achievementRatio},#{stuNumber},#{proportion})")
    void save(AchievementDistribution achievementDistribution);

    @Select("select * from achievement_distribution where coureassess_id = #{coureassessId} and achievement_ratio = #{achievementRatio}")
    AchievementDistribution selectByCoureassessIdAndAchievementRatio(@Param("coureassessId") Integer coureassessId,@Param("achievementRatio") Integer achievementRatio);

//    @Select("select id,coureassess_id,achievement_ratio,stu_number,proportion from achievement_distribution where coureassess_id = #{coureassessId}")
//    List<AchievementDistribution> selectByCoureassessId(Integer coureassessId);

    @Select("select id,coureassess_id,achievement_ratio,stu_number,proportion from achievement_distribution where coureassess_id = #{coureassessId}")
    @Results({
            @Result(property = "coureassessId", column = "coureassess_id"),
            @Result(property = "achievementRatio", column = "achievement_ratio"),
            @Result(property = "stuNumber", column = "stu_number")
    })
    List<AchievementDistribution> selectByCoureassessId(Integer coureassessId);

    @Update("update achievement_distribution " +
            "SET coureassess_id = #{coureassessId}, " +
            "achievement_ratio = #{achievementRatio}, " +
            "stu_number = #{stuNumber}, " +
            "proportion = #{proportion} " +
            "WHERE coureassess_id = #{coureassessId} and achievement_ratio = #{achievementRatio}")
    int update(AchievementDistribution achievementDistribution);
}
